<%@ page language="java" import="java.util.*,com.bean.*,com.dao.*" pageEncoding="utf-8"%>
<%!
	Integer nowPage = 1;
 %>
<%
   UserBean users = (UserBean)session.getAttribute("user");
   if(users == null)
   {
      response.sendRedirect("login.html");
      return ;
   }
   
    FenYe fy = new FenYe();
	//总页数
	int totalPage = fy.getTotalPage();
	//当前页
	//Integer nowPage = 1;
	
	String upPage = request.getParameter("upPage");
	String downPage = request.getParameter("downPage");
	if(upPage!=null){
		int temp = nowPage - Integer.parseInt(upPage);
		if(temp==0){
			out.print("<script>alert('已经是第一页');</script>");
		}else{
			nowPage = temp;
		}
	}
	if(downPage!=null){
		System.out.println(downPage);
		int temp = nowPage + Integer.parseInt(downPage);
		System.out.println(temp);
		if(temp==totalPage+1){
			out.print("<script>alert('已经是最后一页了');</script>");
		}else{
			nowPage = temp;
		}
	}
	
	
	AccountDao dao = new AccountDao();
	
    List<AccountBean> list = fy.getListByPage(nowPage.toString());
%>

<html>
  <head>

    <title>银行卡销毁</title>
 
  </head>
  
  <body>
    <form>
	<table width="100%" cellpadding="10px" cellspacing="0px" border="1px" style="border-collapse:collapse" bordercolor="#CCCCCC">
		<tr>
			<td colspan="4">
				银行卡注册
			</td>
		</tr>
		<tr>
			<td width="30%">
				开户行
			</td>
			<td width="40%">
				卡号
			</td>
			<td width="20%">
				余额
			</td>
			<td width="10%">
				注销
			</td>
		</tr>
		
		<%
		  AccountDao daos = new AccountDao();
		  List<AccountBean> banks = daos.selectAll();
		  for(AccountBean bean : banks)
		  {
		      out.println("<tr>");
		      out.println("<td>"+bean.getBank()+"</td>");
		      out.println("<td>"+bean.getNo()+"</td>");
		      out.println("<td>"+bean.getMoney()+"</td>");
		      out.println("<td><a href='deleteCard.jsp?no="+bean.getNo()+"'>删除</a></td>");
		      out.println("</tr>");
		  }
		%>
		<tr>
    	 	<td colspan=4><a href="destory.jsp?upPage=1" >上一页</a>当前<%=nowPage %>页/共<%=totalPage %>页<a href="destory.jsp?downPage=1" >下一页</a></td>
    	 </tr>
	</table>
	</form>
  </body>
</html>
